package com.android.nfctouch.ui.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.android.nfctouch.R;


/**
 * Created by Administrator on 2018/9/20.
 */

public class EditUserInfoView extends LinearLayout {
    public EditUserInfoView(Context context) {
        super(context);
        this.context = context;
        initView(null);
    }

    public EditUserInfoView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
        initView(attrs);
    }

    public EditUserInfoView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context = context;
        initView(attrs);
    }

    Context context;
    public TextView tv_title, tv_content;
    View view_line;

    private void initView(AttributeSet attrs) {
        View.inflate(context, R.layout.view_edit_userinfo_view, this);
        tv_title = findViewById(R.id.tv_title);
        view_line = findViewById(R.id.view_line);
        tv_content = findViewById(R.id.tv_content);

        if (attrs != null) {
            TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.EditUserInfoView);
            //标题
            String text = typedArray.getString(R.styleable.EditUserInfoView_userinfo_titleName);
            tv_title.setText(text);
            //内容
            String content = typedArray.getString(R.styleable.EditUserInfoView_userinfo_content);
            tv_content.setText(content);

            typedArray.recycle();
        }
    }

    //设置标题
    public void setTv_title(String text) {
        tv_title.setText(text);
    }

    //设置内容
    public void setContent(String text) {
        if (TextUtils.isEmpty(text)) {
            tv_content.setText("未设置");
        } else {
            tv_content.setText(text);
        }

    }
}
